import { createRouter, createWebHistory } from "vue-router";

const Layout = () => import("@/view/Layout.vue");
const Home = () => import("@/view/home/index");
const topCategory = () => import("@/view/category/index");
const subCategory = () => import("@/view/category/sub");

const routes = [
  // 一级路由布局容器
  {
    path: "/",
    component: Layout,
    children: [
      {
        path: "/",
        component: Home,
      },
      {
        path: "/category/:id",
        component: topCategory,
      },
      {
        path: "/category/sub/:id",
        component: subCategory,
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
